package com.hsjk.szwj.module.pay.exception;

import com.hsjk.szwj.module.pay.dal.dataobject.config.ChannelRetMsg;
import lombok.Getter;

/**
 * @author chenjiawei
 * @desc 请求渠道侧异常 exception
 * @Date 2023/08/24 09:26
 **/
@Getter
public class ChannelException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    private ChannelRetMsg channelRetMsg;

    /**
     * 业务自定义异常
     **/
    private ChannelException(ChannelRetMsg channelRetMsg) {
        super(channelRetMsg != null ? channelRetMsg.getChannelErrMsg() : null);
        this.channelRetMsg = channelRetMsg;
    }

    /**
     * 未知状态
     **/
    public static ChannelException unknown(String channelErrMsg) {
        return new ChannelException(ChannelRetMsg.unknown(channelErrMsg));
    }

    /**
     * 系统内异常
     **/
    public static ChannelException sysError(String channelErrMsg) {
        return new ChannelException(ChannelRetMsg.sysError(channelErrMsg));
    }
}
